package com.itboye.shop.app;

import android.app.Activity;
import android.app.Application;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.facebook.drawee.backends.pipeline.Fresco;

import java.lang.ref.WeakReference;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by admin on 2017/1/13.
 */

public class MyApplication extends Application {


    private List<WeakReference<Activity>> activityList = new LinkedList<>();

    public static MyApplication instatnce;

    private static RequestQueue queue;

    public static MyApplication getInstance(){
        return instatnce;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instatnce=this;
        Fresco.initialize(this);
        queue = Volley.newRequestQueue(this);
    }

    public void addActivity(Activity activity) {
        activityList.add(new WeakReference<Activity>(activity));
    }

    /**
     * @return the queue
     */
    public static RequestQueue getQueue() {
        return queue;
    }
    //
    public static <T> void addRequest(Request<T> request) {
        request.addMarker("itboye");
        getQueue().add(request);
    }
}
